package com.zyx.springmvcmsb.request.controller;

import com.zyx.springmvcmsb.rest.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author zyx
 * @since 2021/10/3 08:35
 */
@Controller
public class UserController {

    @RequestMapping("/testUser")
    public String testUser(User user){
        System.out.println(user);
        return "success";
    }

    /**
     * Controller中也支持原生Servlet的对象, 需要在参数中给出
     *      HttpServletRequest
     *      HttpServletResponse
     *      HttpSession
     *      Locale:设置区域信息,国际化的操作
     *      InputStream
     *      OutputStream
     *      Reader
     *      Writer
     */
    @RequestMapping("api")
    public String servletApi(HttpServletRequest request, HttpServletResponse response, HttpSession session){
        request.setAttribute("request","request");
        session.setAttribute("session","session");
        return "success";
    }
}
